#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "window.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QString texdir =QFileDialog::getExistingDirectory(this,tr("请选择轩辕剑贴图目录"),tr("D:\\swdol\\TEX"));
    if(texdir.isEmpty()){
        //QMessageBox::warning(this, tr("出错~"),tr("没有打开文件路径~"));
        return;
    }
    ui->lineEdit->setText(texdir);
}

void MainWindow::on_pushButton_2_clicked()
{
    QString modelpath = QFileDialog::getOpenFileName(this,tr("请打开轩辕剑PLY模型文件"),tr("D:\\swdol\\MODEL\\"),tr("PLY模型文件, IDX索引文件(*.PLY *.IDX)"));
    if(modelpath.isEmpty()){
        //QMessageBox::warning(this, tr("出错~"),tr("没有打开文件路径~"));
        return;
    }
    ui->lineEdit_2->setText(modelpath);

}

//新增：根据个人习惯调整一下操作逻辑，去掉一些提示，添加一个确认打开模型的按钮
void MainWindow::on_pushButton_open_clicked()
{
    QString texdir = ui->lineEdit->text();
    QString modelpath =  ui->lineEdit_2->text();
    if(!modelpath.isEmpty() && !texdir.isEmpty()) {
        Window *w=new Window(modelpath, texdir);
        w->show();
    } else {
        QMessageBox::warning(this, tr("出错~"),tr("路径不能为空~"));
        return;
    }
}
